<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
   public function _initialize(){
		if(session("truename")){
			$str= file_get_contents("socket.txt");
			$this->assign('socket',$str);
		}else{
			  $this->redirect("Login/index"); 
		}
   }
   
	public function home(){
		
		
		layout('Layout/layout');
		$this->display();
	}
	
	public function index(){
		
		$this->redirect("Login/index");
	}
	
	
	public function tongzhi(){
		$tongzhi=D("tongzhi");
		$fenzu =D("fenzu");
		if($_POST){
			
			
		}
		$where="";
	
		 $count =$tongzhi->where($where)->count();
		 $Page= new \Think\Page($count,10);
		 $show= $Page->show();// 分页显示输出
		
		 $list=$tongzhi->where($where)->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		  foreach ($list as $key => &$value) {
				$content = $value["title"];
				$value["title"]=re_substr($content,0,30);
		   }
		  $this->assign('alist',$list);
		  $this->assign('page',$show);
		  
		  $zulist =$fenzu->where("")->select();
		   $this->assign('zulist',$zulist);
		
		$this->assign('index',1);
		layout('Layout/layout');
		$this->display();
		
	}
	function addtongzhi(){
		$tongzhi=D("tongzhi");
	
		
		if($_POST){
			if($_POST["id"]){
				$data["id"] =$_POST["id"];
				$data["title"] =$_POST["title"];
				$data["typename"] =$_POST["typename"];
				$data["username"] = session("truename");
				$data["createtime"] = time();
			
				
				if($tongzhi->save($data)){
					$this->success('修改成功','/index.php/Home/Index/tongzhi');
					
				}else{
					$this->success('修改失败','/index.php/Home/Index/tongzhi');
				}
			}else{
				$data["typename"] =$_POST["typename"];
				$data["title"] =$_POST["title"];
				$data["username"] =session("truename");
				$data["createtime"] = time();
				
				if($tongzhi->add($data)){
					$this->success('添加成功','/index.php/Home/Index/tongzhi');
					
				}else{
					$this->success('添加失败','/index.php/Home/Index/tongzhi');
				}
			}
			
		}else{
			if($_GET["id"]){
				
				
				
				$info =$tongzhi->where("id=".$_GET["id"])->find();
				$this->assign('arr',$arr);
				$this->assign('info',$info);
			}else{
				
				
			}
			
			
		
			
		}
		
		$this->assign('truename',session("truename"));
	
		layout('Layout/layout');
		$this->display();
	}
	function deltongzhi(){
		$ids =$_POST["ids"];
		 $model = D("tongzhi");//获取当期模块的操作对象
		 if(strpos($ids,",")){
			$where = 'id in('.$ids.')';
		  }else{
			$where = 'id='.$ids;
		  }
		   $list=$model->where($where)->delete();
		   if($list!==false) {
			  echo "0";
		   }else{
			  echo "-1";
		   }
		
	}
	public function danwei(){
		$danwei=D("danwei");
		$fenzu=D("fenzu");
			$where="";
		if($_GET["name"]){
			$where=" name like '%".$_GET["name"]."%'";
			
		}
	
	
		 $count =$danwei->where($where)->count();
		 $Page= new \Think\Page($count,10);
		 $show= $Page->show();// 分页显示输出
		
		 $list=$danwei->where($where)->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		  foreach ($list as $key => &$value) {
			$zuid =$value["zuid"];
			if($zuid){
				
					$zuinfo =$fenzu->where("id=".$zuid)->find();
			$value["zuname"]=$zuinfo["zuname"];
			}
		
			
		}
		
		  $this->assign('alist',$list);
		   $this->assign('count',$count);
		  $this->assign('page',$show);
		
		$this->assign('index',3);
		layout('Layout/layout');
		$this->display();
		
	}
	function adddanwei(){
		$danwei=D("danwei");
		$fenzu=D("fenzu");
		
		if($_POST){
			if($_POST["id"]){
				$data["id"] =$_POST["id"];
				$data["name"] =$_POST["name"];
				$data["code"] =$_POST["code"];
				$data["zuid"] =$_POST["zuid"];
				$data["createtime"] = time();
				$data["state"] =$_POST["state"];
				
				if($danwei->save($data)){
					$this->success('修改成功','/index.php/Home/Index/danwei');
					
				}else{
					$this->success('修改失败','/index.php/Home/Index/danwei');
				}
			}else{
				$data["name"] =$_POST["name"];
				$data["code"] =$_POST["code"];
				$data["zuid"] =$_POST["zuid"];
				$data["createtime"] = time();
				$data["state"] =$_POST["state"];
					
				if($danwei->add($data)){
					$this->success('添加成功','/index.php/Home/Index/danwei');
					
				}else{
					$this->success('添加失败','/index.php/Home/Index/danwei');
				}
			}
			
		}else{
			if($_GET["id"]){
				$info =$danwei->where("id=".$_GET["id"])->find();
				$this->assign('info',$info);
			}
			
			 $zulist = $fenzu->where("")->select();
			 $this->assign('types',$zulist);
			
		
			layout('Layout/layout');
			$this->display();
		}
		
		
	
	
	}
	function deldanwei(){
		$ids =$_POST["ids"];
		 $model = D("danwei");//获取当期模块的操作对象
		 if(strpos($ids,",")){
			$where = 'id in('.$ids.')';
		  }else{
			$where = 'id='.$ids;
		  }
		   $list=$model->where($where)->delete();
		   if($list!==false) {
			  echo "0";
		   }else{
			  echo "-1";
		   }
		
	}
	
	
	
	public function appset(){
			$Model = M();
		if($_POST){
			$rtmp = $_POST["rtmp"];
			file_put_contents("system.txt",$rtmp);
			
			
		}else{
			
			$str= file_get_contents("system.txt");
			$this->assign('rtmp',$str);
		}
		layout('Layout/layout');
		$this->display();
	}
	public function appset2(){
			$Model = M();
		if($_POST){
			$apkurl =$_POST["apkurl"];
			$version= $_POST["version"];
			$str= $version."|".$apkurl;
			file_put_contents("app.txt",$str);
		}
			
			$str= file_get_contents("app.txt");
			$items  = explode("|",$str);
			
			$this->assign('version',$items[0]);
			$this->assign('apkurl',$items[1]);
		
		
		$this->assign('index',6);
		layout('Layout/layout');
		$this->display();
	}
	public function tv(){
		
		$tv=D("tv");
		if($_POST){
			
			
		}
		$where="";
	
		 $count =$tv->where($where)->count();
		 $Page= new \Think\Page($count,10);
		 $show= $Page->show();// 分页显示输出
		
		 $list=$tv->where($where)->order('seq asc')->limit($Page->firstRow.','.$Page->listRows)->select();
		  $this->assign('alist',$list);
		  $this->assign('page',$show);

		  $fenzu =D("fenzu");
		$fenzulist = $fenzu->where("")->select();
		$this->assign('fenzulist',$fenzulist);

		
		$this->assign('index',2);
		layout('Layout/layout');
		$this->display();
	}
	
	public function addtv(){
		$tv=D("tv");
	
		
		if($_POST){
			if($_POST["id"]){
				$data["id"] =$_POST["id"];
				$data["name"] =$_POST["name"];
				$data["url"] =$_POST["url"];
				$data["typeid"] =$_POST["typeid"];
				$data["logoimg"] =$_POST["logoimg"];
				$data["logotitle"] =$_POST["logotitle"];
				$data["seq"] =$_POST["seq"];
				$data["state"] =$_POST["state"];
				$data["desc"] =$_POST["desc"];
				$data["nosignalimg"] =$_POST["nosignalimg"];
				
				if($tv->save($data)){
					$this->success('修改成功','/index.php/Home/Index/tv');
					
				}else{
					$this->success('修改失败','/index.php/Home/Index/tv');
				}
			}else{
				$data["name"] =$_POST["name"];
				$data["url"] =$_POST["url"];
				$data["seq"] =$_POST["seq"];
				$data["typeid"] =$_POST["typeid"];
				$data["logoimg"] =$_POST["logoimg"];
				$data["logotitle"] =$_POST["logotitle"];
				$data["state"] =$_POST["state"];
				$data["desc"] =$_POST["desc"];
				$data["nosignalimg"] =$_POST["nosignalimg"];
				
				
				if($tv->add($data)){
					$this->success('添加成功','/index.php/Home/Index/tv');
					
				}else{
					$this->success('添加失败','/index.php/Home/Index/tv');
				}
			}
			
		}else{
			if($_GET["id"]){
				$info =$tv->where("id=".$_GET["id"])->find();
				$this->assign('arr',$arr);
				$this->assign('info',$info);
			}
			
		}
		layout('Layout/layout');
		$this->display();
		
	}
	
	function deltv(){
		$ids =$_POST["ids"];
		 $model = D("tv");//获取当期模块的操作对象
		 if(strpos($ids,",")){
			$where = 'id in('.$ids.')';
		  }else{
			$where = 'id='.$ids;
		  }
		   $list=$model->where($where)->delete();
		   if($list!==false) {
			  echo "0";
		   }else{
			  echo "-1";
		   }
		
	}
	function app(){
		 $menu = D("menu");
		 
	
		$list=$menu->where("")->select();
		 $this->assign('alist',$list);
		$this->assign('index',6);
		layout('Layout/layout');
		$this->display();
	}
	function addmenu(){
		 $menu = D("menu");
		 $Model = M();
		 if($_POST){
				
				$name =$_POST["name"];
				$imgurl =$_POST["imgurl"];
				$code =$_POST["code"];
				$obj = $Model->execute("update menu set name='".$name."',imgurl='".$imgurl."' where code='".$code."'");
				if($obj){
					$this->success('修改成功','/index.php/Home/Index/app');
					
				}else{
					$this->success('修改失败','/index.php/Home/Index/app');
				}
			 
		 }else{
			 $code =$_GET["code"];
				if($code=="001"){
					$chicun ="像素 466 * 687";
					
				}else if($code=="002"){
					$chicun ="像素 466 * 687";
					
				}else if($code=="003"){
					$chicun ="像素 818 * 267";
					
				}else if($code=="004"){
					$chicun ="像素 390 * 390";
					
				}else if($code=="005"){
					$chicun ="像素 390 * 390";
					
				}else if($code=="000"){
					$chicun ="像素 1920 * 1080";
					
				}
			  $menuinfo = $menu->where("code='".$_GET["code"]."'")->find();
			  
			
				$this->assign('chicun',$chicun);
			  $this->assign('info',$menuinfo);
			layout('Layout/layout');
			$this->display();
			 
		 }
		
	}
	function tvshow(){
		$danwei =D("danwei");
		$fenzu =D("fenzu");
		$where=" 1=1 ";
		
		if($_GET["state"]=="1"||$_GET["state"]=="0"){
			
			$where =$where." and online=".$_GET["state"];
		}
		if($_GET["zu"]!="-1"&&$_GET["zu"]){
			
			$where =$where." and zuid=".$_GET["zu"];
		}
		
		$count =$danwei->where($where)->count();
		 $Page= new \Think\Page($count,24);
		 $show= $Page->show();// 分页显示输出
		
		
		
		 $list=$danwei->where($where)->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		  foreach ($list as $key => &$value) {
			  $zuid =$value["zuid"];
			  $zuinfo =$fenzu->where("id=".$zuid)->find();
			  $value["zuname"]=$zuinfo["zuname"];
		  }
		 
		 $zaixiancount  =$danwei->where("online=1")->count();
		 
		 $this->assign('sumcount',$danwei->where("")->count());
		 $this->assign('zaixiancount',$danwei->where("online=1")->count());
		   $this->assign('lixiancount',$danwei->where("online=0 or online is null")->count());
		  $this->assign('alist',$list);
		  
		  $fenzulist =$fenzu->where("")->select();
		  $this->assign('zudata',$fenzulist);
		
		    $this->assign('index',6);
			 $this->assign('page',$show);
			layout('Layout/layout');
			$this->display();
	}
	function tvshowdaochu(){
		$danwei =D("danwei");
		$fenzu =D("fenzu");
		$list=$danwei->where($where)->select();
		$data = array();
		 foreach ($list as $key => &$value) {
			  $zuid =$value["zuid"];       
			  $zuinfo =$fenzu->where("id=".$zuid)->find();
			  $zuname=$zuinfo["zuname"];
			  $danweiname= $value["name"];
			  $jointime=substr($value["jointime"],0,10);
			  $outtime=substr($value["outtime"],0,10);
			  $jointime = date('Y-m-d H:i:s',$jointime);
			  $outtime = date('Y-m-d H:i:s',$outtime);
			  array_push($data,array($danweiname,$zuname,$jointime,$outtime));
		  }
		
        $header='单位名称,所属分组,进入时间,离线时间';
		create_csv($data,$header,"tv.csv");
	}
	function logshow(){
		
		$log =D("log");
		$danwei =D("danwei");
		$fenzu =D("fenzu");
		$where="typeid=".$_GET["typeid"];
		
		if($_GET["stime"]!=""&&$_GET["etime"]!=""){
			$where=$where." and FROM_UNIXTIME(log.createtime) between '".$_GET["stime"]."' and '".$_GET["etime"]."'";
			
		}
		if($_GET["zuid"]){
			
			$where=$where." and fenzu.id=".$_GET["zuid"];
		}
		if($_GET["danweiid"]){
			$where=$where." and danwei.id=".$_GET["danweiid"];
			
		}
	
		 $count =$log->join("danwei on danwei.code=log.code")->where($where)->count();
		 $Page= new \Think\Page($count,10);
		 $show= $Page->show();// 分页显示输出
		
		 $list=$log->join("danwei on danwei.code=log.code")->limit($Page->firstRow.','.$Page->listRows)->select();
		 
		
		 $zudata=$fenzu->where("")->select();
			$this->assign('zudata',$zudata);
			$this->assign('typeid',$_GET["typeid"]);
		$this->assign('stime',$_GET["stime"]);
			 $this->assign('etime',$_GET["etime"]);
		  $this->assign('alist',$list);
		  $this->assign('page',$show);
		  
		  
		$this->assign('index',5);
			layout('Layout/layout');
			$this->display();
	}
	
	function dellog(){
		$ids =$_POST["ids"];
		 $model = D("log");//获取当期模块的操作对象
		 if(strpos($ids,",")){
			$where = 'id in('.$ids.')';
		  }else{
			$where = 'id='.$ids;
		  }
		   $list=$model->where($where)->delete();
		   if($list!==false) {
			  echo "0";
		   }else{
			  echo "-1";
		   }
		
	}
	
	function tvstate(){
		$id =$_POST["id"];
		$state =$_POST["state"];
		$kaihuizuid =$_POST["kaihuizuid"];

		
		 $Model = D(); 
		$list =$Model->execute('update tv set state='.$state.',kaihuizuid='.$kaihuizuid.' where id='.$id);
		   if($list!==false) {
			  echo "0";
		   }else{
			  echo "-1";
		   }
	}
	function clearlogo(){
		$id =$_POST["id"];
		
		 $Model = D(); 
		$list =$Model->execute('update tv set logoimg="" where id='.$id);
		   if($list!==false) {
			  echo "0";
		   }else{
			  echo "-1";
		   }
	}
	
	function danweizu(){
		$fenzu =D("fenzu");
		
		$where="";
	
		 $count =$fenzu->where($where)->count();
		 $Page= new \Think\Page($count,10);
		 $show= $Page->show();// 分页显示输出
		
		 $list=$fenzu->where($where)->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		 
		$this->assign('alist',$list);
		$this->assign('index',3);
		$this->assign('page',$show);
			layout('Layout/layout');
			$this->display();
	}

	
	function delzu(){
		$ids =$_POST["ids"];
		 $model = D("fenzu");//获取当期模块的操作对象
		 if(strpos($ids,",")){
			$where = 'id in('.$ids.')';
		  }else{
			$where = 'id='.$ids;
		  }
		   $list=$model->where($where)->delete();
		   if($list!==false) {
			  echo "0";
		   }else{
			  echo "-1";
		   }
		
	}
	
	function addzu(){
		$fenzu=D("fenzu");
	
		
		if($_POST){
			if($_POST["id"]){
				$data["id"] =$_POST["id"];
				$data["zuname"] =$_POST["zuname"];

		
				if($fenzu->save($data)){
					$this->success('修改成功','/index.php/Home/Index/danweizu');
					
				}else{
					$this->success('修改失败','/index.php/Home/Index/danweizu');
				}
			}else{
				$data["zuname"] =$_POST["zuname"];
			
				if($fenzu->add($data)){
					$this->success('添加成功','/index.php/Home/Index/danweizu');
					
				}else{
					$this->success('添加失败','/index.php/Home/Index/danweizu');
				}
			}
			
		}else{
			if($_GET["id"]){
				
				
				
				$info =$fenzu->where("id=".$_GET["id"])->find();
				
				$this->assign('info',$info);
			}
			
				$this->assign('index',3);
			layout('Layout/layout');
			$this->display();
		
			
		}
		
		
		
	}
	function sendtongzhi(){
		$fenzu=D("fenzu");
		$zulist = $fenzu->where("")->select();
		
		$this->assign('tvid',$_GET["tvid"]);
		$this->assign('types',$zulist);
		$this->display();
	}
	function sendtongzhi2(){
		$fenzu=D("fenzu");
		$zulist = $fenzu->where("")->select();
		$type= $_GET["type"];
		if($type=="滚屏"){
			
				$this->assign('type',"tongzhi");
		}else if($type=="弹屏"){
				$this->assign('type',"tanping");
		}
	
		$this->assign('str',$_GET["str"]);
		$this->assign('types',$zulist);
		$this->display();
	}
	
	function tvshowlog(){
		
		$code =$_GET["code"];
		$log=D("log");
			$where = "code='".$code."' and to_days(FROM_UNIXTIME(createtime)) = to_days(now())";
		
		 $count =$log->where($where)->count();
		 $Page= new \Think\Page($count,10);
		 $show= $Page->show();// 分页显示输出
		 
	
		$list=$log->where($where)->order('id asc')->limit($Page->firstRow.','.$Page->listRows)->select();
		 
		$this->assign('alist',$list);
		$this->assign('index',3);
			layout('Layout/layout');
			$this->display();
	}
	function tongzhilog(){
		$tongzhilog=D("tongzhilog");
		$data["type"]=$_POST["type"];
		$data["content"]=$_POST["content"];
		$data["zuid"]=$_POST["zuid"];
		$data["zulist"]=$_POST["zulist"];
	
		$data["createtime"]=time();
		$data["username"]= session("truename");
		
		if($tongzhilog->add($data)){
					echo "1";
					
				}else{
					echo "0";
		}
	}
	function tongzhiloglist(){
	
		$tongzhilog=D("tongzhilog");
		$fenzu=D("fenzu");
		$tv=D("tv");
		$where = "";
		
		if($_GET["stime"]!=""&&$_GET["etime"]!=""){
			$where=$where." and FROM_UNIXTIME(createtime) between '".$_GET["stime"]."' and '".$_GET["etime"]."'";
			
		}
		
		 $count =$tongzhilog->where($where)->count();
		 $Page= new \Think\Page($count,10);
		 $show= $Page->show();// 分页显示输出
		 
	
		$list=$tongzhilog->where($where)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		foreach ($list as $key => &$value) {
			$zuid =$value["zuid"];
			$tvid =$value["tvid"];
			$type =$value["type"];
			
			if($tvid){
				$tvinfo =$tv->where("id=".$tvid)->find();
				$value["tvname"]=$tvinfo["name"];
			}else{
				$value["tvname"]="全部";
			}
			if($type=="tanping"){
				$value["type"]="弹屏通知";
			}else if($type=="tongzhi"){
				
				$value["type"]="滚屏通知";
			}else if($type=="videotongzhi"){
				
				$value["type"]="视频字幕滚屏";
			}
			$value["content"]=re_substr($value["content"],0,20);
		
			
		}
		if($_GET["typeid"]=="1"){	
				$this->assign('index',1);
		}else if($_GET["typeid"]=="2"){
			$this->assign('index',2);
			
		}
		$this->assign('typeid',$_GET["typeid"]);
		$this->assign('alist',$list);
		$this->assign('page',$show);
			layout('Layout/layout');
			$this->display();
		
	}
	
	public function getdanwei(){
		$danwei=D("danwei");
		$zuid =$_POST["zuid"];
		$list = $danwei->where("zuid=".$zuid)->select();
		$this->ajaxReturn($list,'JSON');
		
	}
	
	
	function logshowdaochu(){
		$log=D("log");
		$fenzu=D("fenzu");
		$danwei=D("danwei");
		$stime =$_GET["stime"];
		$etime =$_GET["etime"];
		$danweiid =$_GET["danweiid"];
		$typeid =$_GET["typeid"];
		
		$where="typeid=".$_GET["typeid"];
		
		if($_GET["stime"]!=""&&$_GET["etime"]!=""){
			$where=$where." and FROM_UNIXTIME(log.createtime) between '".$_GET["stime"]."' and '".$_GET["etime"]."'";
			
		}
		if($_GET["zuid"]){
			
			$where=$where." and fenzu.id=".$_GET["zuid"];
		}
		if($_GET["danweiid"]){
			$where=$where." and danwei.id=".$_GET["danweiid"];
			
		}
	
		
		$list=$log->join("danwei on danwei.code=log.code")->join("fenzu on danwei.zuid = fenzu.id")->where($where)->field("log.*,danwei.zuid")->select();
		$data = array();
		 foreach ($list as $key => &$value) {
			  $zuid =$value["zuid"];       
			  $zuinfo =$fenzu->where("id=".$zuid)->find();
			  $zuname=$zuinfo["zuname"];
			  
			  $code= $value["code"];
			  $danweiinfo =$danwei->where("code='".$code."'")->find();
			  $name = $danweiinfo["name"];
			 
			  
			  $content =$value["content"];
			  $createtime =$value["createtime"]."<br/>";
			  $createtime =date("Y-m-d H:i:s",$value["createtime"]);
			  $typeid =$value["typeid"];
			  $typename="";
			  if($typeid=="0"){
				   $typename="登录日志";
			  }else if($typeid=="1"){
				   $typename="节目浏览日志";
			  }else if($typeid=="3"){
				   $typename="新闻浏览日志";
			  } 
			  print_r($createtime);
			  array_push($data,array($content,$createtime,$name,$zuname,$typename));
		  }
		
        $header='内容,时间,单位,分组,类型';
		
		create_csv($data,$header,"log.csv");
	}
	public function appinfo(){
			$Model = M();
		if($_POST){
		
			$Model->execute("update app set dianbotitle='".$_POST["dianbotitle"]."',dianboimg='".$_POST["dianboimg"]."',socketurl='".$_POST["socketurl"]."'");
			
			
			
		}
		
		$obj=$Model->query("select * from app");
		
		$this->assign('info',$obj[0]);
			
			
		$this->assign('index',6);
		layout('Layout/layout');
		$this->display();
	}
	function updatepass(){
		$Model = M();
		if($_POST){
			$username= session("username");
			$Model->execute("update manage set password='".$_POST["password"]."' where username='".$username."'");
			$this->success('修改成功','/index.php/Home/Login/index');
		}
		layout('Layout/layout');
		$this->display();	
	}
	
	function choosevideo(){
		$dir="./videos/".$_GET["filename"]."/";
		$dir =iconv('utf-8' , 'gbk' , $dir );
		$f=scandir($dir);
		$arr = Array();
		foreach($f as $file) {
			$name =iconv('gbk' , 'utf-8' , $file );
			//print_r($name);
			
			  if(is_dir($dir.$file)){
				    $obj["name"]=$name;
					  $obj["type"]="1";
					  $obj["time"]=filemtime($dir.$file);
			  }else{
				  $obj["name"]=$name;
				  $obj["type"]="0";
				  $obj["time"]=filemtime($file);
				   $obj["url"]="http://".$_SERVER['HTTP_HOST']."/videos/".$_GET["filename"]."/".$name;
			}
		  if(strpos($name,".jpg")>-1){
			 
		  }else if($name=="."){
			  
			  
		  }else if($name==".."){
			  
			  
		  }else{
			   array_push($arr,$obj);
		  }
			//array_push($arr,$name);
		}
		$arr=array_diff($arr,array('.','..'));
			$this->assign('arr',$arr);
			
				$this->assign('filename',$_GET["filename"]);
		
		$this->assign('index',2);
		//$this->ajaxReturn($arr,'JSON');
			$this->display("choosevideo");
	}
	function choosevideo2(){
		//header("Content-Type:text/html;charset=utf-8");
		$dir="./videos/".$_GET["filename"]."/";
		$url='http://'.$_SERVER['HTTP_HOST']."/videos/";
		$this->assign('url',$url);
	
		//$dir =iconv('utf-8' , 'gbk' , $dir );
		$f=scandir($dir);
		
		$arr = Array();
		foreach($f as $file) {
		    $name =iconv('gbk' , 'utf-8' , $file );
			$name= $file;
		
		  if(is_dir($dir.$file)){

			  $obj["name"]=$name;
			  $obj["type"]="1";
			  $obj["time"]=filemtime($dir.$file);
			
		  }else{
			  $obj["name"]=$name;
			  $obj["type"]="0";
			  $obj["time"]=filemtime($file);
			   $obj["url"]="http://".$_SERVER['HTTP_HOST']."/videos/".$_GET["filename"]."/".$name;
		  }
		
		  if(strpos($name,".jpg")>-1){
			 
		  }else if($name=="."){
			  
			  
		  }else if($name==".."){
			  
			  
		  }else{
			   array_push($arr,$obj);
		  }
		}

		$arr=array_diff($arr,array('.','..'));
		
		

		$this->assign('arr',$arr);
		$this->assign('filename',$_GET["filename"]);
		
		$this->assign('index',2);
		
		$this->display();	
	}
	
}